<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div
	style="background-color:rgb(102,102,102); border:0; width:100%; height:80px;z-index:-1;">
	<div class="head" id="head">
		<div id="webbei_logol">
			<img src="img/logo.gif" alt="" title="标识" />
		</div>
		<div class="usercando">
			<div class="usercando_dingzhi" id="usercando_dingzhi">
				<div style="width:70px;height:50px">
					<a href="showProducts" target="_blank"><img
						src="img/head_custom.gif" alt="" title="定制" id="user_dingzhi"
						style="cursor:pointer" /> </a>
				</div>
				<div
					style="position:absolute; top:80px; z-index:1; left:0; display:none"
					id="test">
					<ul style="padding: 0px;margin: 0px;">
						<c:forEach items="${applicationScope.product}" var="p">
							<li style="margin:0"><a
								href="showCustom.action?productId=${p.productId}"><font
									color=white>${p.productName}</font> </a></li>
						</c:forEach>
					</ul>
				</div>
			</div>
			<div class="usercando_share">
				<a href="Share.action" target="_blank"><img
					src="img/head_share.gif" alt="" title="分享" id="user_share" /> </a>
				<div style="position:absolute; top:50px; left:-100px;">
					<ul>
					</ul>
				</div>
			</div>
		</div>
		<div class="search" id="search">
			<div style="width:100%; height:35px; padding-top:10px;"
				id="showusersName">
				<a id="showusersNamefont"><font id="showusersNamefont1" style="font-size:15px;color:#00C"></font>
				</a> <a href="" target="_top" id="showusersNamea"><font
					id="showusersNamea1" style="font-size:10px;"></font>
				</a>
			</div>
			<div style="padding-top:0px;">
				<div style="float:left;">
					<input type="text" value="" id="searchsomething" />
				</div>
				<div style="float:left;">
					<a href=""><img src="img/head_search_bt.gif"
						style="width:30px;height:20px;" alt="" title="查询" /> </a>
				</div>
			</div>
		</div>
		<div class="something_else">
			<div class="something_else_up">
				<div
					style="width:90px; float:left; padding-top:7px; padding-left:30px;font-size:14px;">
					&nbsp;&nbsp;<a href="">加关注</a>
				</div>
				<div
					style="width:100px; float:left; padding-top:2px; padding-left: 10px;">
					<div class="jiathis_style_24x24">
						<a class="jiathis_button_tqq"></a> <a class="jiathis_button_tsina"></a>
						<a href="http://www.jiathis.com/share"
							class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
					</div>
					<script type="text/javascript"
						src="http://v3.jiathis.com/code/jia.js?uid=1356769700443407"
						charset="utf-8"></script>
				</div>
			</div>
			<script type="text/javascript">
				
				function showShopCar(){
					if($("#shopcarcount").html()=='0'){
						alert('购物车中没有商品');
					}else{
						window.location.href="showShopCar.action";
					}
				}
				function checkemail() {
					if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
							.test(document.getElementById("email").value))) {
						$("#email").val("");
					}
				}
				function getCookie(c_name) {
					if (document.cookie.length > 0) {
						c_start = document.cookie.indexOf(c_name + "=");
						if (c_start != -1) {
							c_start = c_start + c_name.length + 1;
							c_end = document.cookie.indexOf(";", c_start);
							if (c_end == -1)
								c_end = document.cookie.length;
							return unescape(document.cookie.substring(c_start,
									c_end));
						}
					}
					return "";
				}
				function deleteSessionAndCookies() {
					$(".loginandresign").show();
					logoutSuccess();
					//删除掉Cookies(OK)
					var usernmae=getCookie("wangbeiCookieUsername");
					if (usernmae) {
						var expiredays = 365;//Cookie保存365天
						var exdate = new Date();
						exdate.setDate(exdate.getDate()+ expiredays);
						document.cookie = "wangbeiCookieUsername="+ ""+ ((expiredays == null) ? "": "; expires="+ exdate.toGMTString());
					}
					$.ajax({
						url : "deleUserSession.action",
						type : "post"
					});
				}
				function loginSuccess(name){
					$("#showusersNamefont1").html(name);
					$("#showusersNamefont").attr("href","ShowMyCustom");
					$("#showusersNamea1").html("退出");
					$("#showusersNamea").attr("href","javascript:deleteSessionAndCookies();");
					setTimeout(function(){
					("#showusersNamea").attr("target","_top");
						},100);
				}
				function logoutSuccess(){
					$("#showusersNamefont1").html("");
					$("#showusersNamefont").attr("href","");
					$("#showusersNamea1").html("");
					$("#showusersNamea").attr("href","");
				}
				function checkLoginAtTop() {
					var email = document.getElementById("email").value;
					var pwd = document.getElementById("pwd").value;
					if (pwd != '' && pwd != null) {
						if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)) {
							$.getJSON("checkLoginAtTop.action",{
								email : email,
								password : pwd
							},
							function(data) {
							
								if (data.customerCount == 1) {
									if (document.getElementById("checkbox").checked) {
										//增加一个Cookie(OK)
										var expiredays = 365;//Cookie保存365天
										var exdate = new Date();
										exdate.setDate(exdate.getDate()+ expiredays);
										document.cookie = "wangbeiCookieUsername="+ escape(data.username)+ ((expiredays == null) ? "": "; expires="+ exdate.toGMTString());
									}
									$(".loginandresign").hide();
									loginSuccess(data.username);
								} else {
									alert('邮箱或密码错误');
								}
							});
						} else {
							alert('邮箱格式错误');
							$("#email").val("");
						}
					} else {
						alert('密码不能为空');
					}
				}
				$(document).ready(function() {
					var ss = '<%=request.getSession().getAttribute("username")%>';
									if (ss == 'null' || ss == "") {
										//alert('session为空');
										username = getCookie('wangbeiCookieUsername');
										if (username != null && username != "") {
											//alert('cookies存在：'+username);
											$.ajax({
												url : "addUserSession.action",
												data : {
													username : username
												},
												type : "post"
											});
											$(".loginandresign").hide();
											loginSuccess(username);
										} else {
											//alert('cookies为空');
										}
									} else {
										//alert('session存在：'+ss);
										$(".loginandresign").hide();
										loginSuccess(ss);
									}
									
									var s1 = '<%=request.getSession().getAttribute("countshopcar")%>';
									if (s1 == 'null' || s1 == "") {
										$("#shopcarcount").html(0);
									} else {
										$("#shopcarcount").html(s1);
									}
								});
			</script>
			<div class="something_else_down">
				<div
					style="width:125px; float:left; padding-top:5px; padding-left:10px;">
					<div style="float:left;">
						<img src="img/head_cart.gif" alt="" title="" />
					</div>
					<div
						style="float:left; height:20px; padding-top:5px;font-size:12px;">
						&nbsp;购物车(<a href="javascript:showShopCar()"><font
							id="shopcarcount" color=red></font> </a>)
					</div>
				</div>
				<div class="loginandresign">
					<div id="login_btn"
						style="float:left; cursor:pointer; font-size:13px;">登陆</div>
					<a href="register.jsp">
						<div id="resign_btn"
							style="float:left; cursor:pointer;font-size:13px;">|注册</div> </a>
					<div id="login_level">
						<div class="login_level_email">
							邮箱：<input type="text" id="email" name="mail"
								onblur="checkemail();" />
						</div>
						<div class="login_level_email">
							密码：<input type="password" id="pwd" name="password" />
						</div>
						<div class="remember_pwd">
							<input type="checkbox" id="checkbox" name="jizhu" value="1" />
							记住我的登录状态&nbsp;&nbsp;<a
								href="<%=request.getContextPath()%>/findpwd.jsp"
								style="font-size:12px;"> 忘记密码？</a> <input type="button"
								value="登录" onclick="checkLoginAtTop();" />
						</div>
						<div class="more_loginway">
							<img src="img/login_qq.png" alt="" title="QQ" /> <img
								src="img/tianya.png" alt="" title="天涯" /> <img
								src="img/twitter.png" alt="" title="推特" /> <img
								src="img/tuita.png" alt="" title="推他" /> <img src="img/msn.png"
								alt="" title="MSN" /> <img src="img/souhuweibo.png" alt=""
								title="搜狐微博" /> <img src="img/qiyiqitan.png" alt=""
								title="奇异奇谈" /> <img src="img/more.png" id="moreway" alt=""
								title="更多" />
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>